package com.ute.chinesechess;

import android.util.Log;

public class Tot extends QuanCo {
	public boolean KiemTra(int i, int j) {
		if (i >= 0 && i <= 9 && j >= 0 && j <= 8) {
			if (Phe == 0) {
				if (i == Hang + 1 && j == Cot) {
					if (BanCo.board[i][j].Trong == false) {
						if (BanCo.board[i][j].Phe != this.Phe)
							return true;
					}
					else
						return true;
				}
				if(i>=5){
					if (i == Hang && j == Cot - 1) {
						if (BanCo.board[i][j].Trong == false) {
							if (BanCo.board[i][j].Phe != this.Phe)
								return true;
						}
						else
							return true;
					}
					if (i == Hang && j == Cot + 1) {
						if (BanCo.board[i][j].Trong == false) {
							if (BanCo.board[i][j].Phe != this.Phe)
								return true;
						}
						else
							return true;
					}
				}
				return false;
			}
			else {
				if (i == Hang - 1 && j == Cot) {
					if (BanCo.board[i][j].Trong == false) {
						if (BanCo.board[i][j].Phe != this.Phe)
							return true;
					}
					else
						return true;
				}
				if(i<5){
					if (i == Hang && j == Cot - 1) {
						if (BanCo.board[i][j].Trong == false) {
							if (BanCo.board[i][j].Phe != this.Phe)
								return true;
						}
						else
							return true;
					}
					if (i == Hang && j == Cot + 1) {
						if (BanCo.board[i][j].Trong == false) {
							if (BanCo.board[i][j].Phe != this.Phe)
								return true;
						}
						else
							return true;
					}
				}
				return false;
			}
		}
		return true;
	}
	
	public void veLogBanCo() {
		for (int i = 0; i < 10; i++) {
			Log.d("Hang" + i, BanCo.board[i][0].Phe + " "
					+ BanCo.board[i][1].Phe + " " + BanCo.board[i][2].Phe + " "
					+ BanCo.board[i][3].Phe + " " + BanCo.board[i][4].Phe + " "
					+ BanCo.board[i][5].Phe + " " + BanCo.board[i][6].Phe + " "
					+ BanCo.board[i][7].Phe + " " + BanCo.board[i][8].Phe);
		}
	}
}
